package com.tedu.bill.demo2;

import java.util.*;

/**
 * Author：毕龙
 * Date: 2024/5/19 15:50
 */
public class TestMap {
    public static void main(String[] args) {
        HashMap<Integer, String> map = new HashMap<>();
        //map集合中的key是一个set集合
        //set集合中数据不可以重复 因此key=1的数据被覆盖
        map.put(1,"龙龙");
        map.put(1,"王伟");
        map.put(2,"王伟");
        map.put(3,"龙龙");
        map.put(4,"龙龙");
        map.put(5,"龙龙");
        map.put(6,"龙龙");
        map.put(7,"龙龙");
        map.put(8,"龙龙");
        map.put(9,"龙龙");
        map.put(10,"龙龙");
        map.put(11,"龙龙");
        map.put(12,"龙龙");
        map.put(13,"龙龙");
        map.put(14,"龙龙");
        map.put(15,"龙龙");

        //将map集合转化为一个keySet
        Set<Integer> set = map.keySet();
        set.forEach(i->{
            System.out.println(i+"--->"+map.get(i));
        });

        //将map集合转化为一个EntrySet
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        entries.forEach(System.out::println);

        //遍历所有值
        Collection<String> values = map.values();
        values.forEach(System.out::println);


    }
}
